<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

/**
 * App\Models\WithdrawLog
 *
 * @property int $id
 * @property string $openid openid
 * @property int $status 1-已申请未提交，2-已申请已提交，3-平台发放到位
 * @property float $amount 1-图片,2-视频
 * @property \Carbon\Carbon|null $created_at
 * @property \Carbon\Carbon|null $updated_at
 * @property string|null $deleted_at
 * @method static bool|null forceDelete()
 * @method static \Illuminate\Database\Query\Builder|\App\Models\WithdrawLog onlyTrashed()
 * @method static bool|null restore()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\WithdrawLog whereAmount($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\WithdrawLog whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\WithdrawLog whereDeletedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\WithdrawLog whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\WithdrawLog whereOpenid($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\WithdrawLog whereStatus($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\WithdrawLog whereUpdatedAt($value)
 * @method static \Illuminate\Database\Query\Builder|\App\Models\WithdrawLog withTrashed()
 * @method static \Illuminate\Database\Query\Builder|\App\Models\WithdrawLog withoutTrashed()
 * @mixin \Eloquent
 */
class WithdrawLog extends Model
{
    use SoftDeletes;

    const STATUSES = [
        1 => '申请中',
        2 => '已提现',
        3 => '已拒绝',
    ];

    public function getStatusWordAttribute()
    {
        if (isset(self::STATUSES[$this->status])) {
            return self::STATUSES[$this->status];
        }
        return '未知';
    }

    public function member()
    {
        return $this->hasOne(Member::class, 'openid', 'openid');
    }

    public function member_account()
    {
        return $this->hasOne(MemberAccount::class, 'openid', 'openid');
    }
}
